<%@ page import="java.util.Map" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.io.StringReader" %>
<%@ page import="java.io.Reader" %>
<%@ page import="org.tigr.htc.persist.*" %>
<%@ page import="org.tigr.htc.common.*" %>
<%@ page import="org.tigr.htc.cmd.*" %>
<%@ page import="org.apache.log4j.Logger" %>

<%!
    static Logger log = Logger.getLogger(IPersist.class);
%>

<html>
<head>
</head>

<body>
<%

String title = "Create a New Command";
String createRequest = request.getParameter("createRequest");
if((createRequest != null) && (createRequest.equals("t"))) {
    try {
	String cmdXML = request.getParameter("requestXML");
	StringReader fr = new StringReader(cmdXML);
	Command cmd = (Command) CommandHelper.getInstance().unmarshal((Reader) fr);
	log.info(" done unmarshalling of the XML <br>");
	//	Param p = new Param("ttt", "vvv");
	//	cmd.addParam(p);

// 	Iterator it = cmd.getParams().iterator();
// 	Param p = (Param) it.next();
// 	out.println("Param");
// 	out.println("t " + p.getType());
// 	out.println("v " + p.getValue());
// 	out.println("id " + p.getCommand().getID());

	IPersist pl = PersistFactory.getIPersist();
	long id = pl.getNewID();
	cmd.setID(id);
	pl.create(cmd);
    } catch(Exception e) {
	title = "Create Command failed: " + e.getMessage();
    }
	
}
%>


<%=title%>
<form method="post" action="request_create.jsp">
<input type="hidden" name="createRequest" value="t" />

Request XML:<br>
<textarea name="requestXML" rows="50" cols="110">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;command type=&quot; &quot;&gt;
    &lt;executable&gt; &lt;/executable&gt;

    &lt;name&gt; &lt;/name&gt;
    &lt;username&gt; &lt;/username&gt;
    &lt;group&gt; &lt;/group&gt;
    &lt;id&gt; &lt;/id&gt;

    &lt;state&gt; &lt;/state&gt;
    &lt;initialDir&gt; &lt;/initialDir&gt;
    &lt;retryCount&gt; &lt;/retryCount&gt;

    &lt;times&gt; &lt;/times&gt;
    &lt;config&gt;
        &lt;opSys&gt; &lt;/opSys&gt;
        &lt;passThrough&gt; &lt;/passThrough&gt;
        &lt;logLocation&gt; &lt;/logLocation&gt;
        &lt;length&gt; &lt;/length&gt;
        &lt;priority&gt; &lt;/priority&gt;
        &lt;memory&gt; &lt;/memory&gt;
        &lt;getenv&gt; &lt;/getenv&gt;
        &lt;class&gt; &lt;/class&gt;
    &lt;/config&gt;

    &lt;param type=&quot;PARAM&quot;&gt;
        &lt;key&gt; &lt;/key&gt;
        &lt;value&gt; &lt;/value&gt;
    &lt;/param&gt;

    &lt;param type=&quot;FILE&quot;&gt;
        &lt;key&gt; &lt;/key&gt;
        &lt;value&gt; &lt;/value&gt;
    &lt;/param&gt;

    &lt;status&gt;
        &lt;message&gt; &lt;/message&gt;
        &lt;errors&gt; &lt;/errors&gt;

        &lt;running&gt; &lt;/running&gt;
        &lt;completed&gt; &lt;/completed&gt;
        &lt;waiting&gt; &lt;/waiting&gt;
        &lt;returnValue&gt; &lt;/returnValue&gt;
    &lt;/status&gt;

&lt;/command&gt;

</textarea>

<input type="submit" value="submit" />
</form>
<hr>
tigr copyright notice here

</body>
</html>
